templateViewInit = ()=>{
    window.$contextRoot = system_config.basePath;
    searchFormInfo();

    // 已知数据渲染
    var inst = table.render({
        elem: '#model-list',
        id:'model-list-id',
        height: '#content-body-150',
        url: top.tools.getBaseUrl()+'/activiti/getPage',
        method: 'post',
        headers:{
            'Access-Token':top.tools.cookie.token(),
            'Content-Type':'application/json',
        },
        toolbar: '#dictToolbar',
        defaultToolbar: ['filter', 'exports', 'print', { // 右上角工具图标
            title: '提示',
            layEvent: 'LAYTABLE_TIPS',
            icon: 'layui-icon-tips',
            onClick: function (obj) { // 2.9.12+
                layer.alert('自定义工具栏图标按钮');
            }
        }],
        cols: [
            [
                {type: 'checkbox', width: 50},
                {type: 'numbers', title: '序号', align: 'center', width: 80},
                {field: 'name', title: '模型名称', align: 'left', minWidth: 200},
                {field: 'key', title: 'KEY', align: 'center',width: 120},
                {field: 'category', title: '类型', align: 'left',minWidth: 100},
                {field: 'deploymentId', title: '部署ID', align: 'left',minWidth: 100},
                {field: 'resourceName', title: '资源路径', align: 'left',minWidth: 100},
                {field: 'version', title: '版本', align: 'left',width: 80},
                {fixed: 'right', title: '操作', align: 'center',  width: 170, toolbar: '#operateRow'}
            ]
        ],
        parseData: dataToFormat,
        data:[
            {id:1,name:'用户性别',type:'system_user_sex',status:'0',remark:'',createTime:'2021-01-05 17:03:48'}
        ],
        //skin: 'line', // 表格风格
        //even: true,
        page: true, // 是否显示分页
        limits: [15, 20, 30,50],
        limit: 15, // 每页默认显示的数量
        done: function (res, curr, count) {
            $(".layui-table th[data-field=" + 0 + "] .layui-table-cell").html("");
        }
    });
    // 工具栏事件
    table.on('toolbar(model-list)', function (obj) {
        var id = obj.config.id;
        var checkRow = table.checkStatus(id);
        if (checkRow.data.length<=0 && obj.event !== 'add'){
            layer.msg("请选择数据！");
            return
        }
        var data = checkRow.data;
        if (obj.event === 'add') {
            openForm({
                title:"新增域名证书",
                btn:1,
                save:(closeid)=>{
                    formFun.save(inst,closeid)
                },
                reset:(closeid)=>{
                    form.val('model_form', top.tools.form.getFindElementOnObj("#lay-model-form",false));
                },
                before:(index,layero,that,isEdit)=>{
                    workdbFieldConvert(document.querySelectorAll('#lay-model-form .dict-module'),isEdit);
                    form.val('model_form', {
                        sort:table.cache['model-list-id'].length+1,
                        status:true
                    });
                },
                area:'40%'
            },'model_form')
        } else if (obj.event === 'apply') {
            const resultN = data.filter(item =>item.issuedAt).map(item=>item.domain);
            if (resultN.length>0){
                layer.confirm(resultN.join('<br>'), {icon: 3,title:'以下域名已申请证书，是否重新申请'}, function(){
                    formFun.apply(data)
                }, function(){
                    formFun.apply(data.filter(item =>item.issuedAt))
                })
            }else {
                formFun.apply(data)
            }

        } else  if (obj.event === 'renew') {
            const resultN = data.filter(item =>!item.issuedAt).map(item=>item.domain);
            if (resultN.length>0){
                layer.confirm(resultN.join('<br>'), {icon: 3,title:'以下域名已申请证书，请先申请证书'}, function(){
                    formFun.apply(data.filter(item =>!item.issuedAt))
                })
            }else {
                formFun.renew(data)
            }
        }
    });
    // 触发单元格工具事件
    table.on('tool(model-list)', function (obj) { // 双击 toolDouble
        var data = obj.data; // 获得当前行数据
        if (obj.event === 'view') {
            openForm({
                title:"模型在线设计",
                type:2,
                btn:-1,
                area:['99%','99%'],
                content:[system_config.basePath+'/activiti_modeler/modeler.html?modelId='+data.id, 'yes'],
                before:(index,layero,that,isEdit)=>{

                }
            })
        } else if (obj.event === 'del') {
            openConfirm(()=>{
                formFun.remove(data,inst)
            });
        }
    });


    queryButton('model-list-id');
    formReset();
}


var formFun = {
    apply:(data)=>{
        top.API.ssl().apply(data,(res)=>{
            layer.msg(res.message)
        })
    },
    renew:(data)=>{
        top.API.ssl().renew(data,(res)=>{
            layer.msg(res.message)
        })
    },
    save:(modelTable,closeid)=>{
        let formData = top.tools.form.getFindElementOnObj("#lay-model-form",true);
        if (typeof formData === 'boolean'){
            return;
        }

        top.API.ssl().save(formData,(res)=>{
            layer.msg(res.message, {icon: 1}, function(){
                // layer.msg('提示框关闭后的回调');
                if (modelTable){
                    table.reloadData('model-list-id', {
                        where: {}, // 数据异步请求时携带的字段集 --- 属性设置有效，因属于数据相关属性
                        scrollPos: true, // 设定重载数据或切换分页时的滚动条的位置状态 --- 属性设置有效
                        page: {
                            curr: modelTable.config.page.curr,
                            limit: modelTable.config.page.limit
                        }
                    });
                }
                if (closeid){
                    layer.close(closeid);
                }
            });
        })
    },
    remove:(data,modelTable)=>{
        top.API.ssl().del(data,(res)=>{
            layer.msg(res.message, {icon: 1}, function(){
                // layer.msg('提示框关闭后的回调');
                if (modelTable){
                    table.reloadData('model-list-id', {
                        where: {}, // 数据异步请求时携带的字段集 --- 属性设置有效，因属于数据相关属性
                        scrollPos: true, // 设定重载数据或切换分页时的滚动条的位置状态 --- 属性设置有效
                        page: {
                            curr: modelTable.config.page.curr,
                            limit: modelTable.config.page.limit
                        }
                    });
                }
            });
        })
    },
    setValue:(data,eleId)=>{
        data.status = parseInt(data.status);
        form.val(eleId, data);
    }
}